import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 资产信息 */
export interface Companyproperty {
  id: number // id
  hostName?: string // IP地址
  name: string // 名称
  deviceType: number // 设备类型
  businessType: string // 业务类型
  area: string // 区域
  manufacturer: string // 厂商
  model: string // 型号
  serial: string // 序列号
  manufactureDate: string | Dayjs // 生产日期
  warrantyDate: string | Dayjs // 质保到期日期
  location: string // 设备分布位置
}

// 资产 API
export const CompanypropertyApi = {
  // 查询资产分页
  getCompanypropertyPage: async (params: any) => {
    return await request.get({ url: `/business/company-property/page`, params })
  },

  // 查询资产详情
  getCompanyproperty: async (id: number) => {
    return await request.get({ url: `/business/company-property/get?id=` + id })
  },

  // 新增资产
  createCompanyproperty: async (data: Companyproperty) => {
    return await request.post({ url: `/business/company-property/create`, data })
  },

  // 修改资产
  updateCompanyproperty: async (data) => {
    return await request.put({ url: `/business/company-property/update`, data })
  },

    // 修改设备
    updateDevices: async (data) => {
      return await request.put({ url: `/business/company-property/updateDevice`, data })
    },

  // 删除资产
  deleteCompanyproperty: async (id: number) => {
    return await request.delete({ url: `/business/company-property/delete?id=` + id })
  },

  /** 批量删除资产 */
  deleteCompanypropertyList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/company-property/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出资产 Excel
  exportCompanyproperty: async (params) => {
    return await request.download({ url: `/business/company-property/export-excel`, params })
  }
}
